// pages/myExamStack/examDetail/examDetail.js
var util = require('../../../utils/util.js');
const config = require('../../../utils/config');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    examDetail: '',
    examId: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      examId: options.examId
    })
    wx.request({
      url: config.examUrl + '/exam-detail-byid',
      data: {
        examId: options.examId,
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        console.log( res.data)
        var examDetail = res.data;
        if(examDetail != null){
          for(var i=0; i<examDetail.length;i++){
            examDetail[i].effTime = util.formatTimeTwo(examDetail[i].effTime,'Y-M-D h:m:s');
            examDetail[i].expTime = util.formatTimeTwo(examDetail[i].expTime,'Y-M-D h:m:s');
            examDetail[i].createTime = util.formatTimeTwo(examDetail[i].createTime,'Y-M-D h:m:s');
           
          }
          that.setData({
            examDetail: examDetail,
          })
        }
      },
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  
  //开始考试
  examStart:function(event){
    var that = this;
    wx.navigateTo({
      url: '../examStart/examStart?examId='+ that.data.examId,
    })
  },

  //模拟考试
  modelExamStart:function(event){
    var that = this;
    wx.navigateTo({
      url: '../modelExamStart/modelExamStart?examId='+ that.data.examId,
    })
  },

  //查看详情
  examDetail:function(event){
    var that = this;
    wx.navigateTo({
      url: '../userExamDetail/userExamDetail?examId='+that.data.examId,
    })
  }
})